using System;
using System.Globalization;
using GammaJul.ReSharper.GammaXaml.Highlightings.Xaml;
using JetBrains.Annotations;
using JetBrains.ProjectModel;
using JetBrains.ReSharper.Daemon;
using JetBrains.ReSharper.Daemon.Xaml.Highlightings;
using JetBrains.ReSharper.Psi.Resolve;

[assembly: RegisterConfigurableSeverity(
	ElementNameNotResolvedHighlighting.SeverityId,
	null,
	HighlightingGroupIds.CodeSmell,
	ElementNameNotResolvedHighlighting.Description,
	ElementNameNotResolvedHighlighting.Description,
	Severity.ERROR,
	false)]

namespace GammaJul.ReSharper.GammaXaml.Highlightings.Xaml {

	/// <summary>
	/// An highlighting that indicates that the ElementName of a Binding cannot be resolved.
	/// </summary>
	[ConfigurableSeverityHighlighting(SeverityId, XamlProjectFileType.Name, AttributeId = HighlightingAttributeIds.UNRESOLVED_ERROR_ATTRIBUTE, OverlapResolve = OverlapResolveKind.UNRESOLVED_ERROR)]
	public class ElementNameNotResolvedHighlighting : XamlResolveErrorHighlightingBase {
		internal const string SeverityId = "Xaml.ElementNameNotResolvedHighlighting";
		internal const string Description = "Binding.ElementName not resolved";

		/// <summary>
		/// Initializes a new instance of the <see cref="ElementNameNotResolvedHighlighting"/> class.
		/// </summary>
		/// <param name="reference">The unresolved reference.</param>
		public ElementNameNotResolvedHighlighting([NotNull] IReference reference)
			: base(reference,  String.Format(CultureInfo.InvariantCulture, "Cannot resolve element named '{0}'", reference.GetName())) {
		}
	}

}
